package com.dingwen.treasure.web.excption.handler.impl;

import com.dingwen.treasure.base.exception.BaseExceptionHandler;
import com.dingwen.treasure.base.pojo.vo.Result;
import com.dingwen.treasure.base.pojo.vo.ResultGenerator;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;


/**
 * 　IllegalArgumentExceptionHandlerImpl
 * 　@author dingwen
 * 　@date 2022/5/17$
 */
@Component("java.lang.IllegalArgumentException")
public class IllegalArgumentExceptionHandlerImpl extends BaseExceptionHandler<Void> {

    /**
     * 根据异常构建统一返回结果
     *
     * @param exception 异常
     * @return result
     */
    @Override
    public Result<Void> buildResultByException(Exception exception) {
        IllegalArgumentException illegalArgumentException = (IllegalArgumentException) exception;
        return ResultGenerator.genFailureResult(illegalArgumentException.getMessage(), HttpStatus.BAD_REQUEST.value());
    }
}
